﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using Telerik.Web.UI;
using System.ComponentModel;

namespace BSCMFF.Web.UserControls.Details
{
    /// <summary>
    /// Personal KPI details.
    /// </summary>
    /// <remarks></remarks>
    public partial class PKPIDetails : System.Web.UI.UserControl
    {
        /// <summary>
        /// Gets the name.
        /// </summary>
        /// <remarks></remarks>
        public String Name
        {
            get
            {
                return RadTextBoxName.Text;
            }
        }

        /// <summary>
        /// Gets the description.
        /// </summary>
        /// <remarks></remarks>
        public String Description
        {
            get
            {
                return RadTextBoxDescription.Text;
            }
        }

        /// <summary>
        /// Gets the measure.
        /// </summary>
        /// <remarks></remarks>
        public String Measure
        {
            get
            {
                return RadTextBoxMeasure.Text;
            }
        }
        
        /// <summary>
        /// Gets the weight.
        /// </summary>
        /// <remarks></remarks>
        public int Weight
        {
            get
            {
                return (int)RadNumericTextBoxWeight.Value;
            }
        }

        /// <summary>
        /// Gets the start value.
        /// </summary>
        /// <remarks></remarks>
        public int? StartValue
        {
            get
            {
                return (int?)RadNumericTextBoxStartValue.Value;
            }
        }

        /// <summary>
        /// Gets the target value.
        /// </summary>
        /// <remarks></remarks>
        public int? TargetValue
        {
            get
            {
                return (int?)RadNumericTextBoxTargetValue.Value;
            }
        }

        /// <summary>
        /// Gets the current value.
        /// </summary>
        /// <remarks></remarks>
        public int CurrentValue
        {
            get
            {
                return RadNumericTextBoxCurrentValue.Value == null ? (int)RadNumericTextBoxStartValue.Value : (int)RadNumericTextBoxCurrentValue.Value;
            }
        }

        /// <summary>
        /// Gets the KP i_ FK.
        /// </summary>
        /// <remarks></remarks>
        public int? KPI_FK
        {
            get
            {
                if (RadComboBoxKPIs.SelectedValue == "")
                {
                    return null;
                }
                else
                {
                    return Int32.Parse(RadComboBoxKPIs.SelectedValue);
                }
            }
        }

        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Roles.IsUserInRole("Manager"))
            {
                
            }

        }

        /// <summary>
        /// Disables the PKPI properties.
        /// </summary>
        /// <remarks></remarks>
        private void DisablePKPIProperties()
        {
            foreach (Control c in this.Controls)
            {
                if (c.GetType().Name == typeof(RadTextBox).Name)
                {
                    ((RadTextBox)c).Enabled = false;
                }
                if(c.GetType().Name == typeof(RadNumericTextBox).Name)
                {
                    ((RadNumericTextBox)c).Enabled = false;
                }
            }
        }
    }
}